use std::fmt::Display;
use rbatis::rbdc::datetime::DateTime;
use crate::domain::vo::user::SysUserVO;
use serde::{Deserialize, Serialize};
use crate::domain::table::SysRole;

///的后的所有信息，保存到redis
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UserCache {
    pub id: String,
    pub user_name: String,
    pub ipaddr: String,
    pub login_location: String,
    pub os: String,
    pub browser: String,
    pub user: Option<SysUserVO>,
    pub permissions: Vec<String>,
    pub menu_ids: Vec<u64>,
    pub roles: Vec<SysRole>,
    pub login_time: DateTime,
    pub token_key:String
}

impl Display for UserCache {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", serde_json::json!(self).to_string())
    }
}
